﻿using System;
using System.Web.Mvc;

namespace Avalon.Core.MVC.Attributes {

    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
    public class IgnoreEntityAttribute : Attribute, IMetadataAware {
        public const string Key = "IgnoreEntity";
        public bool Ignore { get; set; }

        public IgnoreEntityAttribute(bool ignore) {
            Ignore = ignore;
        }

        public IgnoreEntityAttribute() : this(true) { }


        public void OnMetadataCreated(ModelMetadata metadata) {
            metadata.AdditionalValues[Key] = Ignore;
        }
    }

}
